package com.winit.openapi.sms.validator;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.winit.openapi.util.ValidateUtil;

/**
 * 
 * 卖家代付人
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * keke.xu 	1.0  		2016年3月11日 	Created
 *
 * </pre>
 * @since 1.
 */
public class SellerAdvanceFieldValidator {

    /**
     * 校验创建卖家代付人参数校验
     * 
     * @param json
     */
    public static void validCreateField(JSONObject json) {
        ValidateUtil.validNotNull(json, "advanceName");
        ValidateUtil.validMaxLength(json, "advanceName", 32);
    }

    /**
     * 校验创建卖家代付人参数校验
     * 
     * @param json
     */
    public static void validCreateField(JSONObject json, String name) {
        ValidateUtil.validNotNull(json, name);
    }

    /**
     * 校验代付人是否为空
     */
    public static void validCreateAdvance(JSONObject json, String splat) {
        JSONArray result = json.getJSONArray(splat);
        for (int i = 0; i < result.size(); i++) {
            ValidateUtil.validNotNull(result.getJSONObject(i), "advanceName");
            ValidateUtil.validMaxLength(result.getJSONObject(i), "advanceName", 75);
            ValidateUtil.validNotNull(result.getJSONObject(i), "advanceType");
        }

    }
}
